package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Echarts;
import com.ruoyi.system.service.IEchartsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据图Controller
 * 
 * @author ruoyi
 * @date 2023-12-04
 */
@RestController
@RequestMapping("/system/echarts")
public class EchartsController extends BaseController
{
    @Autowired
    private IEchartsService echartsService;

    /**
     * 查询数据图列表
     */
    @PreAuthorize("@ss.hasPermi('system:echarts:list')")
    @GetMapping("/list")
    public TableDataInfo list(Echarts echarts)
    {
        startPage();
        List<Echarts> list = echartsService.selectEchartsList(echarts);
        return getDataTable(list);
    }

    /**
     * 导出数据图列表
     */
    @PreAuthorize("@ss.hasPermi('system:echarts:export')")
    @Log(title = "数据图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Echarts echarts)
    {
        List<Echarts> list = echartsService.selectEchartsList(echarts);
        ExcelUtil<Echarts> util = new ExcelUtil<Echarts>(Echarts.class);
        util.exportExcel(response, list, "数据图数据");
    }

    /**
     * 获取数据图详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:echarts:query')")
    @GetMapping(value = "/{newVisitis1}")
    public AjaxResult getInfo(@PathVariable("newVisitis1") String newVisitis1)
    {
        return success(echartsService.selectEchartsByNewVisitis1(newVisitis1));
    }

    /**
     * 新增数据图
     */
    @PreAuthorize("@ss.hasPermi('system:echarts:add')")
    @Log(title = "数据图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Echarts echarts)
    {
        return toAjax(echartsService.insertEcharts(echarts));
    }

    /**
     * 修改数据图
     */
    @PreAuthorize("@ss.hasPermi('system:echarts:edit')")
    @Log(title = "数据图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Echarts echarts)
    {
        return toAjax(echartsService.updateEcharts(echarts));
    }

    /**
     * 删除数据图
     */
    @PreAuthorize("@ss.hasPermi('system:echarts:remove')")
    @Log(title = "数据图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{newVisitis1s}")
    public AjaxResult remove(@PathVariable String[] newVisitis1s)
    {
        return toAjax(echartsService.deleteEchartsByNewVisitis1s(newVisitis1s));
    }
}
